package service;

import entity.StatisticsResult;
import entity.TimeResult;
import mapper.StatisticsMapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * @author Ray
 * @date 2020/6/20 10:44
 */
@Service
public class StatisticsServiceImpl implements StatisticsService {
    @Autowired
    private StatisticsMapper statisticsMapper;

    @Override
    public List<StatisticsResult> customerOrder() {
        List<StatisticsResult> list=statisticsMapper.customerOrder();
        return list;
    }

    @Override
    public List<StatisticsResult> managerOrder() {
        List<StatisticsResult> list=statisticsMapper.managerOrder();
        return list;
    }

    @Override
    public TimeResult selectByYear(String time) {
        TimeResult result=statisticsMapper.selectByYear(time);
        return result;
    }

    @Override
    public List<TimeResult> selectByMonth(String time) {
        List<TimeResult> results=statisticsMapper.selectByMonth(time);
        return results;
    }

    @Override
    public List<TimeResult> selectByDay(String time, String days) {
        List<TimeResult> results=statisticsMapper.selectByDay(time,days);
        return results;
    }

    @Override
    public List<StatisticsResult> selectSort(String params) {
        List<StatisticsResult> list=null;
        if (params.equals("1")){
            list = statisticsMapper.selectByCredit();
        }else if (params.equals("2")){
            list = statisticsMapper.selectByGrade();
        }else if (params.equals("3")){
            list = statisticsMapper.selectByMaturity();
        }else if (params.equals("4")){
            list = statisticsMapper.selectBySource();
        }else if (params.equals("5")){
            list = statisticsMapper.selectByStatus();
        }else if (params.equals("6")){
            list = statisticsMapper.selectByType();
        }
        for (StatisticsResult ordersChartsVo : list) {
            if (ordersChartsVo.getName()==null){
                ordersChartsVo.setName("未分类");
            }
        }
        return list;

    }

}
